/*
 * Copyright (c) 2013, FPX and/or its affiliates. All rights reserved.
 * Use, Copy is subject to authorized license.
 */
package pyip.lib.javalearn.thread.interrupt;

import pyip.lib.javalearn.Printer;

/**
 * sleep进入睡眠状态后也是可中断的
 * @author yepeng
 * @date 2015年5月20日
 */
public class InterruptSleepDemo {

    public static void main(String[] args) {
        Printer.out.println("main start", 0);
        
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                Printer.out.println("t1 start", 1);
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    Printer.out.println("t1 interrupted", 1);
                    e.printStackTrace();
                }
            }
        });
        t1.start();
        
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Printer.out.println("main interrupt t1", 0);
        t1.interrupt();
    }
    
}
